feat(audience)!: add IdentityType, rename alias params to id/identityType#2836
Merged
Conversation
Add IdentityType as a const-object-plus-type export in @imtbl/audience-core, re-exported through @imtbl/audience. Values mirror the backend OAS IdentityType enum exactly (passport, steam, epic, google, apple, discord, email, custom). A new types.test.ts guards against drift. The const form lets studios import a runtime value (for dropdowns, enum-style access via IdentityType.Passport) while the type form keeps compile-time narrowing available for SDK method signatures that will use it in subsequent commits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename identify/alias parameters so they match the backend wire format.
The SDK now accepts { id, identityType } objects instead of { uid, provider },
narrowing identityType to the IdentityType union exported from
@imtbl/audience-core so invalid providers (e.g. 'foo') fail at compile time
rather than at the backend.
Before:
audience.identify('user-123', 'passport', { email: '...' });
audience.alias({ uid: 'steam-id', provider: 'steam' },
{ uid: 'passport-id', provider: 'passport' });
After:
audience.identify('user-123', 'passport', { email: '...' });
audience.alias({ id: 'steam-id', identityType: 'steam' },
{ id: 'passport-id', identityType: 'passport' });
BREAKING CHANGE: alias() now takes { id, identityType } objects instead
of { uid, provider }. identify()'s positional string argument stays the
same but is now typed as IdentityType instead of string.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7 tasks
|
View your CI Pipeline Execution ↗ for commit 7da2977
☁️ Nx Cloud last updated this comment at |
nattb8
reviewed
Apr 8, 2026
nattb8
reviewed
Apr 8, 2026
6 tasks
nattb8
reviewed
Apr 9, 2026
7a073b4 to
7da2977
Compare
nattb8
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation change for the audience SDK: adds the shared
IdentityTypeunion and narrows the web SDK to use it.IdentityTypeconst + type — shared identity type in@imtbl/audience-corematching the backend's OAS enum (passport | steam | epic | google | apple | discord | email | custom). Exported as both a const object (for runtime values) and a type alias (for parameter typing).identify()andalias()params —identify()'s positional string arg changes type fromstring→IdentityType.alias()parameter shape also changes from{ uid, provider }→{ id, identityType }to match backend wire field names (fromId/fromType/toId/toType).Commits
feat(audience-core): export IdentityType const + type— the union + JSDoc pointer to the backend OASfeat(audience)!: use IdentityType for identify() and alias() params— BREAKING, see belowalias()now takes{ id, identityType }objects instead of{ uid, provider }.identify()'s positional string arg keeps the same name but changes type fromstring→IdentityType.Nothing from this package has been published externally, so the rename is safe to land — but calling it out so reviewers can push back if they disagree.
Tickets
stringparams to be narrowed; this PR also renamesuid/provider→id/identityTypefor parity with backend wire field names. Flagging for review.Scope
This branch previously also contained commits for a
TransportResultrefactor, error propagation, and anAudienceErrorsurface onAudience.init(). Those have been split out based on reviewer feedback that the transport/queue/errors layer needs deeper design work — unified error sink in core rather than sdk, collapsing theTransportinterface, fixing a partial-success silent-drop inMessageQueue.flush, and wiringonErrorthrough pixel. Landing identity types first unblocks the demo PR.Test plan
pnpm --filter @imtbl/audience-core --filter @imtbl/audience --filter @imtbl/pixel test— 203 tests pass (90 core + 49 sdk + 64 pixel)What's next
feat/audience-web-sdk-demo) builds the interactive demo page on top of this branch once it lands.🤖 Generated with Claude Code